package com.cloud.alibaba.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.server.WebExceptionHandler;
import org.springframework.web.server.WebFilter;

/**
 * @author 刘志强
 * @date 2020/9/25 15:31
 */
@Configuration
public class SentinelConfig {

    /**
     * 自定义Sentinel过滤器
     * @return
     */
    @Bean
    @Order(-2)
    public WebFilter sentinelWebFluxFilter()
    {
        return new MySentinelWebFluxFilter();
    }

    /**
     * 自定义异常处理器
     * @return
     */
    @Bean
    @Order(Ordered.HIGHEST_PRECEDENCE)
    public WebExceptionHandler sentinelBlockExceptionHandler() {
        return new MySentinelBlockExceptionHandler();
    }
}
